package org.example.logindemo.controller;

import lombok.extern.slf4j.Slf4j;
import org.example.logindemo.bean.RegisterForm;
import org.example.logindemo.bean.RegisterFormDTO;
import org.example.logindemo.bean.RegisterFormVO;
import org.example.logindemo.bean.UserVO;
import org.example.logindemo.result.Result;
import org.example.logindemo.service.RegisterService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class RegisterController {
    @Autowired
    private RegisterService registerService;

    @PostMapping("/api/register")
    public Result<RegisterFormVO> Register(@RequestBody RegisterFormDTO registerFormDTO) {
        log.info("员工登录：{}", registerFormDTO);
        RegisterForm registerForm = registerService.save(registerFormDTO);
        RegisterFormVO registerFormVO = new RegisterFormVO();
        BeanUtils.copyProperties(registerForm, registerFormVO);

        return Result.success(registerFormVO);
    }
}
